#看代码写结果
v={}
for index in range(10):
    v['users']=index
print(v)
#要求
#1.页面显示 序号+商品名称+商品价格，如：
#1 电脑 1999
#2 鼠标 10
#2.用户输入选择的商品序号，然后打印商品名称及商品价格
#3.如果用户输入的商品序号有误，则提示输入有误，并重新输入.
#4.用户输入Q或者q，退出程序
'''
想显示每个商品，for
输入选择的商品，input
输入的序号，打印的商品名称以及价格
输入有误，    重新输入 while
Q或q upper() break
'''
# for good in range(len(goods)):
#     print(good+1,goods[good]['name'],goods[good]['price'])
# #枚举 enumerate(iterable,start=0)
# l1=['a','b','c']
# for i in enumerate(l1,start=100):
#     print(i)
'''
for i in enumerate(goods):
    print(i)
(0, {'name': '电脑', 'price': 1999})
(1, {'name': '鼠标', 'price': 10})
(2, {'name': '游艇', 'price': 20})
(3, {'name': '美女', 'price': 998})
s1='0212313'
print(s1.isdecimal())#判断是否是正整数

'''
goods=[
    {'name':"电脑",'price':1999},
    {'name':"鼠标",'price':10},
    {'name':"游艇",'price':20},
    {'name':"美女",'price':998}
]
while 1:
    for num,dic in enumerate(goods):
        print('{}\t{}\t{}'.format(num+1,dic['name'],dic['price']))
    choise_num=input('请输入商品序号:').strip()#重点 strip()
    if choise_num.isdecimal():
        choise_num=int(choise_num)
        if 0<choise_num<=len(goods):#choice_num=2
            print('您选择的商品名为{},价格为{}'.format(goods[choise_num-1]['name'],goods[choise_num-1]['price']))
        else:
            print('您输入的超出范围,请重新输入')
    elif choise_num.upper()=='Q':break
    else:
        print('你输入了非字母元素，请重新输入')

cars=['鲁A32444','鲁B12333','京B8989M','黑C49678','黑C46555','沪 B25041','鄂A88888']
locals={'沪':'上海','黑':'黑龙江','鲁':'山东','鄂':'湖北','湘':'湖南','京':'北京'}
#结果:{'山东': 2, '北京': 1, '黑龙江': 2, '上海': 1, '湖北': 1}
#循环遍历的主题cars
#在循环中给字典添加键值对
#没有键，就创建一个键

dic={}
for i in cars:
    if locals[i[0]] not in dic:
        dic[locals[i[0]]]=1#第一次,dic={'山东':1}
    else:
        dic[locals[i[0]]]=dic[locals[i[0]]]+1
print(dic)

cars=['鲁A32444','鲁B12333','京B8989M','黑C49678','黑C46555','沪 B25041','鄂A88888']
locals={'沪':'上海','黑':'黑龙江','鲁':'山东','鄂':'湖北','湘':'湖南','京':'北京'}
dic={}
for i in cars:
    dic[locals[i[0]]]=dic.get(locals[i[0]],0)+1
print(dic)

























